﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<ThietBiSo.LinQDB.LoaiTinTuc>" %>

<%@ Import Namespace="ThietBiSo.LinQDB" %>
<%@ Import Namespace="ThietBiSo.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Website - bảng điều khiển
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   <script type="text/javascript">

       function loaitintuc_delete(ma) {
            var cnf = window.confirm("Bạn chắc chắn xóa?");
            if (cnf) {
                $.ajax({
                    type: "POST",
                    url: '<%=Url.Action("Delete") %>',
                    cache: false,
                    async: false,
                    dataType: "json",
                    data: { ma: ma },
                    success: function (result) {
                        if (result.length == 0) { // ko tồn tại                        
                            //                            alert("Xóa dữ liệu thành công.");
                            window.location.reload();
                        }
                        else {
                            alert(result);
                        }
                    }
                });
            }

        }
        function loaitintuc_hienthi(ma) {

            $.ajax({
                type: "POST",
                url: '<%=Url.Action("HienThi") %>',
                cache: false,
                async: false,
                dataType: "json",
                data: { ma: ma },
                success: function (result) {
                }
            });
        }
    </script>
    <table width="100%" cellpadding="2" cellspacing="0" border="0">
        <tr>
            <td>
                <table width="100%">
                    <tr>
                        <td class="">
                          <%= Html.ActionLink("Thêm danh mục tin tức", "Create",null, new { @class = "classThem" })%>
                        </td>
                        <td align="right">
                            <%: Html.ActionLink("Quay lại", "quantri", "Admin", null, new { @class = "" })%>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        
        <tr>
            <td colspan="2">
                <table id="bang_admin" class="tbl colorize" width="100%" border="0">
                    <tbody>
                        <tr>
                            <th style="text-align: center" width="50">
                                TT
                            </th>
                           
                            <th align="left">
                              Tiêu đề danh mục
                            </th>
                         
                            <th align="center" style="width: 100px; text-align: center;">
                                Hiển thị
                            </th>
                            <th align="center" width="30">
                                Xóa
                            </th>
                        </tr>
                    </tbody>
                    <tbody>
                        <% foreach (LoaiTinTuc sp in (List<LoaiTinTuc>)ViewData["loaitintucs"])
                           {               
                        %>
                        <tr class="tb_hienthi">
                            <td align="center" valign="middle">
                                <input type="text" disabled="disabled" autocomplete="off" class="orderbox" value="<%:sp.ThuTu %>"
                                    maxlength="4" id="thutu" style="width: 20px;" />&nbsp;
                            </td>
                           
                            <td align="left">
                                <a href="<%=Url.Action("Edit","loaitintuc", new { id = sp.MaLoaiTinTuc} ) %>">
                                    <%: sp.TenLoaiTinTuc%></a>
                            </td>
                            
                            <td align="center">
                                <%if (sp.HienThi == false)
                                  {
                                %>
                                <a href="javascript:loaitintuc_hienthi(<%:sp.MaLoaiTinTuc%>);">
                                    <input type="checkbox" />
                                </a>
                                <%}
                                  else
                                  {%>
                                <a href="javascript:loaitintuc_hienthi(<%:sp.MaLoaiTinTuc%>);">
                                    <input type="checkbox" checked="checked" /></a>
                                <%} %>
                            </td>
                            <td align="center">
                                <a href="javascript:loaitintuc_delete(<%:sp.MaLoaiTinTuc %>);">
                                    <img src="../../Content/imagesAdmin/images/pic_trash.gif" alt="" /></a>
                            </td>
                        </tr>
                        <% } %>
                    </tbody>
                </table>
            </td>
        </tr>
        <tr>
            <td style="text-align: center; clear: both; width: 100%; padding: 20px 0 10px 0;">
                <% if ((string)ViewData["pageLinks"] != "")
                   { %>
                <%= ViewData["pageLinks"] %>
                <% } %>Tổng: <strong>
                    <%= ViewData["total"]%></strong>
            </td>
        </tr>       
    </table>
</asp:Content>

